/*
 * Copyright (c) 2008 by 1eEurope (Switzerland) AG, Thalwil
 *
 * Customer:	1eEurope (Switzerland) AG
 * Project:		BKS
 * Created:		30.09.2008, WBL
 *
*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace By1eEurope.BKS.UserControlZone
{
    /// <summary>
    /// Definition class of the BKS Image Field Type.
    /// </summary>
    public class UserControlZoneField : SPFieldMultiLineText
    {
        public UserControlZoneField(SPFieldCollection fields, string fieldName)
            : base(fields, fieldName)
        { this.Init(); }

        public UserControlZoneField(SPFieldCollection fields,
                           string typeName,
                           string displayName)
            : base(fields, typeName, displayName)
        { this.Init(); }
        
        public override BaseFieldControl FieldRenderingControl
        {
            get
            {
                BaseFieldControl fldControl = new UserControlZone();
                fldControl.FieldName = InternalName;
                return fldControl;
            }
        }

        public override object GetFieldValue(string value)
        {
            return new UserControlZoneValue(value);
        }

        private void Init()
        {
            this.WebSiteUrl = this.GetCustomProperty("WebSiteUrl") + "";
            this.ListTitle = this.GetCustomProperty("ListTitle") + "";
        }

        private string webSiteUrl;
        public string WebSiteUrl
        {
            get { return this.webSiteUrl; }
            set { this.webSiteUrl = value; }
        }
        private string listTitle;
        public string ListTitle
        {
            get { return this.listTitle; }
            set { this.listTitle = value; }
        }

        public override void Update()
        {
            this.SetCustomProperty("WebSiteUrl", this.WebSiteUrl);
            this.SetCustomProperty("ListTitle", this.ListTitle);
            base.Update();
        }

    }
}
